#ifndef __Pch_H__
#define __Pch_H__

#if defined(__WIN32__) || defined(_WIN32)
#include "windows.h"
#endif
#include "Base.h"

#define new RKT_NEW
#include "ReMath.h"
#include "RenderEngine/RenderEngineInc.h"
#include "RenderEngine/RenderEngineCommon.h"
#include "RenderEngine/IFontManager.h"
#include "RenderEngine/BufferDef.h"
#include "RenderEngine/IBufferManager.h"
#include "RenderEngine/VertexData.h"
#include "RenderEngine/IndexData.h"
#include "RenderEngine/PixelFormat.h"
#include "RenderEngine/Image.h"
#include "RenderEngine/ITextureManager.h"
#include "RenderEngine/RenderOperation.h"
#include "RenderEngine/IRenderEngine.h"
#include "RenderEngine/RenderSystemCapabilities.h"
#include "RenderEngine/IRenderSystem.h"
#include "RenderEngine/Light.h"
#include "RenderEngine/IShaderManager.h"
#include "RenderEngine/Viewport.h"

using namespace rkt;

#define PLATFORM_NULL		0
#define PLATFORM_WIN32		1
#define PLATFORM_IOS		2
#define PLATFORM_ANDROID	3

#define RENDER_SYSTEM_NULL  0
#define RENDER_SYSTEM_DX9   1
#define RENDER_SYSTEM_GL    2
#define RENDER_SYSTEM_GLES2 3

//add by kevin.chen
//platform!
#ifdef _WIN32 
	#define PLATFORM PLATFORM_WIN32

	//#define RENDER_SYSTEM RENDER_SYSTEM_GL
	#define RENDER_SYSTEM RENDER_SYSTEM_GLES2

#else
	#define PLATFORM PLATFORM_IOS
	#define RENDER_SYSTEM RENDER_SYSTEM_GLES2
#endif

//render system
#if RENDER_SYSTEM == RENDER_SYSTEM_GLES2
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include <EGL/eglplatform.h>
#else
	#include <GL/glew.h>
	#if PLATFORM == PLATFORM_WIN32
		#include <GL/wglew.h>
	#endif

#endif


#if RENDER_SYSTEM == RENDER_SYSTEM_GLES2
#define glGenBuffersARB glGenBuffers
#define glBindBufferARB glBindBuffer
#define glBufferDataARB glBufferData
#define glDeleteBuffersARB glDeleteBuffers
#define glGetBufferSubDataARB glGetBufferSubData
#define glBufferSubDataARB glBufferSubData
#define GLhandleARB	GLuint
#define glGetUniformLocationARB glGetUniformLocation
#define glUniform1iARB glUniform1i
#define glUniform1fARB glUniform1f
#define glUniform4fARB glUniform4f
#define glUniform3fARB glUniform3f
#define GL_WRITE_ONLY   GL_WRITE_ONLY_OES
#define GL_READ_ONLY	GL_BUFFER_ACCESS_OES
#define GL_READ_WRITE	GL_BUFFER_MAPPED_OES
#define GLdouble		GLfloat

inline bool TestGLError(const char* pszLocation)
{
	GLint iErr = glGetError();
	if (iErr != GL_NO_ERROR)
	{
		printf("%s failed (%d).\n", pszLocation, iErr);
		return false;
	}
	return true;
}	
#endif


#if PLATFORM == PLATFORM_IOS
#define glMapBuffer glMapBufferOES
#define glUnmapBuffer glUnmapBufferOES
#endif


#include "IPerfProf.h"

#endif